﻿using GRPCClass;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SdtpsNodeLibrary
{
    public class TaskReplyWorker
    {
        System.Threading.Thread mythd;
        public void Start()
        {
            mythd = new System.Threading.Thread(new System.Threading.ThreadStart(Execute));
            mythd.Start();

        }
        public bool isStop
        {
            get;
            set;
        }
        /// <summary>
        /// 把提交中心节点失败的重新提交到中心节点
        /// </summary>
        public void Execute()
        {
            do
            {
                while(TaskNodeHandle.taskReplyErrs.Count > 0)
                {
                    TaskReply mytrp = TaskNodeHandle.taskReplyErrs.Dequeue();
                    TaskReply trg= TaskNodeHandle.ReplyNode(mytrp);
                    if (trg.Message != "成功")
                    {
                        System.Threading.Thread.Sleep(2000);
                    }
                    else
                    {
                        System.Threading.Thread.Sleep(50);
                    }
                }
                System.Threading.Thread.Sleep(5000);
            }
            while (!isStop);
        }
    }
}
